package com.woniuxy.microaftersaleserver.reviewmag.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microaftersaleserver.reviewmag.mapper.ReviewServiceMapper;
import com.woniuxy.microaftersaleserver.reviewmag.service.IReviewService;
import com.woniuxy.microcommonserver.bean.aftersales_cyx.ReviewGoods;
import com.woniuxy.microcommonserver.pageHelper.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Transactional(readOnly = true)
@Service
public class ReviewServiceImpl implements IReviewService {

    @Resource
    private ReviewServiceMapper reviewServiceMapper;

    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
    @Override
    public void addReviewService(ReviewGoods reviewGoods) {
        reviewServiceMapper.addReviewService(reviewGoods);
    }

    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
    @Override
    public void deleteReviewService(int id) {
reviewServiceMapper.deleteReviewService(id);
    }

    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
    @Override
    public void updateReviewService(ReviewGoods reviewGoods) {
reviewServiceMapper.updateReviewService(reviewGoods);
    }

    @Override
    public PageInfo<ReviewGoods> findByParams(PageRequest request, ReviewGoods reviewGoods) {
      PageInfo<ReviewGoods> pageInfo= PageHelper.startPage(request.getPageNum(),request.getLimit()).doSelectPageInfo(()->reviewServiceMapper.findByParams(request,reviewGoods));
       return pageInfo;
    }
}
